package com.hhit.collaborative_learning.learning;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql;
import com.mysql.jdbc.StringUtils;

public class SaveCommentServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String userId=request.getParameter("userId");
		String blogId=request.getParameter("blogId");
		String content=request.getParameter("content");
		String parentIdStr=request.getParameter("parentId");
		int parentId=StringUtils.isNullOrEmpty(parentIdStr)?0:Integer.parseInt(parentIdStr);
		PublicDaoImplMySql dao=new PublicDaoImplMySql();
		response.getWriter().print(dao.saveComment(Integer.parseInt(userId), Integer.parseInt(blogId), content, parentId));
	}

}
